﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Business.WPF;
using DataAccess.Exceptions;
using Model;
using Presenters.WPF.Views;

namespace Presenters.WPF
{
    public class NewInscriptionPresenter
    {
        public INewInscriptionView View { get; set; }

        public NewInscriptionPresenter(INewInscriptionView view)
        {
            this.View = view;
        }
        public void SubmitNewInscription()
        {
            try
            {
                if (String.IsNullOrEmpty(this.View.gestion))
                    throw new ValidationException("Seleccione un valor para todos los campos");
                else
                {
                    Inscription inscription = new Inscription();
                    NewInscriptionManager nim = new NewInscriptionManager();
                    nim.NewInscription(this.View.ciEstudiante, this.View.codMateria, this.View.gestion + "-" + DateTime.Today.Year.ToString());



                }
            }
            catch (ValidationException)
            {
                throw new ValidationException("Seleccione un valor para todos los campos");
            }
        }
        public void SubmitModifyInscription()
        {
            try
            { 
                if(String.IsNullOrEmpty(View.ciEstudiante.ToString()) || 
                    String.IsNullOrEmpty(View.codMateria.ToString())||
                    String.IsNullOrEmpty(View.gestion))
                    throw new ValidationException("Llenar todos los campos");

                Inscription inscription = new Inscription();
                NewInscriptionManager nim = new NewInscriptionManager();
                nim.ModifyInscription(View.ciEstudiante, View.codMateria, View.gestion + "-" + DateTime.Today.Year.ToString(), View.codI, View.score1, View.score2, View.score3);

            }
            catch (ValidationException)
            {
                throw new ValidationException("Llenar todos los campos.");
            }
        }
    }
}
